package io.lckgroup.modules.lck.utils;

import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author huangrui
 */
public class MakeOrderIdUtil {

    public static synchronized String makeOrderId() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String newDate = sdf.format(new Date());
        String result = "";
        try {
            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            for (int i = 0; i < 6; i++) {
                result += random.nextInt(10);
            }
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        return newDate + result;
    }
}
